package com.mz.ozy.mvp.model;

import android.content.Context;

import com.mz.ozy.constants.Constants;
import com.mz.ozy.net.RetrofitUtils;
import com.mz.ozy.utils.JsonUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.ResponseBody;

public class ReturnModel {


    public Observable<ResponseBody> onUpdate(Context context, String id, String apply_service, String refund_reason, String num, String instructions, List<String> imgs, int type, String url) {
        HashMap<String, String> map = new HashMap<>();
        if (type == 1) {
            map.put("id", id);
        } else {
            map.put("tesq", id);
        }

        map.put("apply_service", apply_service);
        map.put("refund_reason", refund_reason);
        map.put("num", num);
        map.put("instructions", instructions);

        if (imgs.size() > 0) {
            for (int i = 0; i < imgs.size(); i++) {
                map.put("img" + (i + 1), imgs.get(i));
            }
        }
        return RetrofitUtils.getApiService(context).post(url, JsonUtils.requestJsonDate(map), null);
    }

    public Observable<ResponseBody> getList(Context context, String pageNo) {
        Map<String, String> maps = new HashMap<>();
        maps.put("pageNo", pageNo);
        maps.put("pageSize", Constants.PageSize);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10035, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> getListDetail(Context context, String id) {
        Map<String, String> maps = new HashMap<>();
        maps.put("tesq", id);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10036, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> getWl(Context context, String id, String company, String number) {
        Map<String, String> maps = new HashMap<>();
        maps.put("tesq", id);
        maps.put("company", company);
        maps.put("number", number);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10041, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> getListDetail(Context context, String tesq, String consistent, String logistics, String attitude, String plist, int beanType) {
        if (beanType == 0) {
            Map<String, String> maps = new HashMap<>();
            maps.put("tesq", tesq);
            maps.put("consistent", consistent);
            maps.put("logistics", logistics);
            maps.put("attitude", attitude);
            maps.put("plist", plist);
            return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10023, JsonUtils.requestJsonDate(maps), Constants.tokenId);
        } else {
            Map<String, String> maps = new HashMap<>();
            maps.put("tesq", tesq);
            maps.put("consistent", consistent);
            maps.put("logistics", logistics);
            maps.put("attitude", attitude);
            maps.put("plist", plist);
            return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10300, JsonUtils.requestJsonDate(maps), Constants.tokenId);
        }
    }

    public Observable<ResponseBody> getShDetail(Context context, String id) {
        Map<String, String> maps = new HashMap<>();
        maps.put("id", id);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10037, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> getCanclInviteDetail(Context context, String id) {
        Map<String, String> maps = new HashMap<>();
        maps.put("tesq", id);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10040, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }
}